//
//  LSZGoodsVC.m
//  JKFuYinProject
//
//  Created by 九酷 on 2018/6/13.
//  Copyright © 2018年 LC. All rights reserved.
//

#import "LSZGoodsVC.h"

@implementation LSZGoodsVC
 
- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout{
    self = [super initWithFrame:frame collectionViewLayout:layout];
    if (self) {
        self.dataSource = self;
        self.delegate = self;
        self.backgroundColor = [UIColor whiteColor];
        [self registerClass:[LSZGoodsCollectionViewCell class] forCellWithReuseIdentifier:@"LSZGoodsCollectionViewCell"];
    }
    return self;
}

- (void)setModel:(LSZSignInformationManager *)model{
    _model = model;
    [self reloadData];
}
//-(void)setModelArray:(NSArray *)modelArray
//{
//    self.modelArray = modelArray;
//    [self reloadData];
//}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    LSZSignInformationMg * mg = nil;
    mg = self.model.arrayData[0];
    return mg.advArray.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    LSZGoodsCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"LSZGoodsCollectionViewCell" forIndexPath:indexPath];
    LSZSignInformationMg * mg = nil;
    mg = self.model.arrayData[0];
    LSZSignInformationMg * manager = nil;
    manager = mg.advArray[indexPath.row];
    [cell.imageViewGoods sd_setImageWithURL:[NSURL URLWithString:manager.banner] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    cell.labelTitle.text = manager.title;
    cell.labelMoney.text = [NSString stringWithFormat:@"¥ %@",manager.price];
    cell.labelMoney.tintColor = redUIColor;
    cell.backgroundColor = [UIColor whiteColor];
    return cell;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    LSZSignInformationMg * mg = nil;
    mg = self.model.arrayData[0];
    LSZSignInformationMg * manager = nil;
    manager = mg.advArray[indexPath.row];
   //点击方
    if (_pushBlock != nil) {
        _pushBlock(manager);
    }
}
@end
